blob: e7a216d6d9e12578decb546f55ccad2f7337eee7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import { auth, get } from "$lib/utils";
import { redirect } from "@sveltejs/kit";
export async function load({ cookies, params, parent }) {
const { user } = await parent();
const aid = cookies.get("aid") || user.id;
const { address, amount } = params;
const { balance } = await get(`/account/${aid}`, auth(cookies));
let invoice;
try {
invoice = await get(`/invoice/${address}`);
} catch (e) {
// invoice not found
}
if (invoice) {
const recipient = await get(`/users/${invoice.uid}`);
let r = `/pay/${recipient.username}`;
if (amount) r += `/${amount}`;
if (recipient?.id !== user.id) redirect(307, r);
}
return { balance };
}
|